fix(tui): flush OSC 52 clipboard write, propagate errors on fallback#35289
fix(tui): flush OSC 52 clipboard write, propagate errors on fallback#35289maorizenberg wants to merge 1 commit into
Conversation
- Replace process.stdout.write with fs.writeSync for OSC 52 escape sequence to ensure immediate flush to TTY fd - Add -i flag to xclip command for explicit stdin read - Remove .catch(() => undefined) from clipboard write paths so errors propagate to caller and show error toast instead of false 'Copied to clipboard' - Update test to include -i flag in xclip expected args
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PRs Found:
Most relevant: PR #12129 appears to be the closest match—it also fixes the OSC 52 stdout buffering issue on Linux, though it uses |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Fixes #4283
Type of change
What does this PR do?
Copy-to-clipboard on Linux Wayland (e.g., Ubuntu 24.04) showed "Copied to clipboard" toast but paste returned old content. Two bugs:
OSC 52 escape sequence used
process.stdout.write()which buffers/interleaves with TUI rendering — terminal never processes sequence. Changed tofs.writeSync(process.stdout.fd, ...)for immediate flush to TTY fd.All clipboard write paths silently caught errors with
.catch(() => undefined), swallowing failures when no clipboard tool (wl-copy,xclip) available. Removed catch — errors now propagate to caller which shows error toast.Also added
-iflag to xclip command for explicit stdin read.How did you verify your code works?
Tested on Ubuntu 24.04 Wayland without
wl-clipboardinstalled. Copy now works via OSC 52. All 192 existing tests pass. Typecheck clean across all 36 packages.Screenshots / recordings
N/A (terminal fix, no UI change)
Checklist